/**   
 * @Title: GetBeidanHemaiDetailInfoCommunicater.java 
 * @Package com.esun.rabbit2.communicaters.beijingdanchang 
 * @Description: TODO(用一句话描述该文件做什么) 
 * @author: City Jiangsy@500wan.com   
 * @date: 2011-12-8 下午5:27:10  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.beijingdanchang;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.model.UserInfo;
import com.esun.model.beijingdanchang.BeidanHemaiDetailInfo;
import com.esun.model.beijingdanchang.BeidanHemaiDetailTeamInfo;
import com.esun.network.ServerCommunicater;
import com.esun.util.HashMapUtil;

/**
 * @ClassName: GetBeidanHemaiDetailInfoCommunicater
 * @Description: 获取北单合买详情
 * @author: City Jiangsy@500wan.com
 * @date: 2011-12-8 下午5:27:10
 * 
 */
public class GetBeidanHemaiDetailInfoCommunicater extends ServerCommunicater {

	private String msgServer; // 服务器信息
	private boolean isSucceed = false;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}


	public boolean isGetDetailSucced(String programId, String termNum) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(HashMapUtil.getMapItem(BussinessCode.PASER_MID, BussinessCode.MID_HEMAI_DETIAL_BEIDAN));
		list.add(HashMapUtil.getMapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		list.add(HashMapUtil.getMapItem(Key.KEY_LOTID, Config.BEIJINGZUQIUDANCHANG));
		list.add(HashMapUtil.getMapItem(Key.KEY_PID, programId));
		list.add(HashMapUtil.getMapItem(Key.KEY_EXPECT, termNum));
		// 写入服务器返回信息
		super.getServerResponse(list, true);
		setMsgServer(super.getErrorMSG());
		if (super.getState() == 100) {
			isSucceed = true;
		} else {
			isSucceed = false;
		}
		return isSucceed;
	}

	public void updateDetailInfo() {
		BeidanHemaiDetailInfo beidanHemaiDetailInfo = BeidanHemaiDetailInfo.getBeidanHemaiDetailInfo();
		Hashtable<String, String> result = new Hashtable<String, String>();
		result = super.getResult();
		beidanHemaiDetailInfo.cleanAll();

		beidanHemaiDetailInfo.setJindu(result.get(Key.KEY_RENQI));
		beidanHemaiDetailInfo.setUsername(result.get(Key.KEY_USERNAME));
		beidanHemaiDetailInfo.setAllmoney(result.get(Key.KEY_ALLMONEY));
		beidanHemaiDetailInfo.setBeishu(result.get(Key.KEY_BEISHU));
		beidanHemaiDetailInfo.setAnumber(result.get(Key.KEY_ANUMBER));
		beidanHemaiDetailInfo.setLeftnumber(result.get(Key.KEY_LEFTNUMBER));
		beidanHemaiDetailInfo.setOnemoney(result.get(Key.KEY_ONEMONEY));

		beidanHemaiDetailInfo.setBaodimoney(result.get(Key.KEY_BAODIMONEY));
		beidanHemaiDetailInfo.setTicheng(result.get(Key.KEY_TICHENG));
		beidanHemaiDetailInfo.setIsmanyuan(result.get(Key.KEY_ISMANYUAN));
		beidanHemaiDetailInfo.setLotterycount(result.get(Key.KEY_LOTTERYCOUNT));
		beidanHemaiDetailInfo.setLotterymonery(result.get(Key.KEY_LOTTERYMONERY));
		beidanHemaiDetailInfo.setAddtime(result.get(Key.KEY_ADDTIME));
		beidanHemaiDetailInfo.setIssuc(result.get(Key.KEY_ISSUC));
		beidanHemaiDetailInfo.setIsshow(result.get(Key.KEY_ISSHOW));
		beidanHemaiDetailInfo.setFileorcode(result.get(Key.KEY_FILEORCODE));
		beidanHemaiDetailInfo.setNfileorcode(result.get(Key.KEY_NFILEORCODE));
		beidanHemaiDetailInfo.setDanma(result.get(Key.KEY_DANMA));
		beidanHemaiDetailInfo.setGgtypename(result.get(Key.KEY_GGTYPENAME));
		beidanHemaiDetailInfo.setGggroup(result.get(Key.KEY_GGGROUP));
		ArrayList<BeidanHemaiDetailTeamInfo> teamList = new ArrayList<BeidanHemaiDetailTeamInfo>();
		for (int i = 0; i < super.getListResult().size(); i++) {
			BeidanHemaiDetailTeamInfo beidanHemaiDetailTeamInfo = BeidanHemaiDetailTeamInfo.getBeidanHemaiDetailTeamInfo();
			Hashtable <String, String>listResult = new Hashtable<String, String>();
			listResult = super.getListResult().get(i);
			beidanHemaiDetailTeamInfo.setGuestteamname(listResult.get(Key.KEY_GUESTTEAMNAME));
			beidanHemaiDetailTeamInfo.setHometeamname(listResult.get(Key.KEY_HOMETEAMNAME));
			beidanHemaiDetailTeamInfo.setIsdm(listResult.get(Key.KEY_ISDM));
			beidanHemaiDetailTeamInfo.setLeaguematchname(listResult.get(Key.KEY_LEAGUEMATCHNAME));
			beidanHemaiDetailTeamInfo.setOrdernum(listResult.get(Key.KEY_ORDERNUM));
			beidanHemaiDetailTeamInfo.setRangqiu(listResult.get(Key.KEY_RANGQIU));
			beidanHemaiDetailTeamInfo.setShotin(listResult.get(Key.KEY_SHOTIN));
			teamList.add(beidanHemaiDetailTeamInfo);
		}
		beidanHemaiDetailInfo.setTeamList(teamList);
		beidanHemaiDetailInfo.setIsUpload(result.get(Key.KEY_ISUPLOAD));
		beidanHemaiDetailInfo.setIsChaser(result.get(Key.KEY_ISCHASER));

	}
}
